package com.example.firstapplication;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.telephony.gsm.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SmsMessageActivity extends Activity {
	private EditText phoneNumber;
	private EditText smsContent;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.smsmessage);
		phoneNumber=(EditText)this.findViewById(R.id.edit_PhoneNumber);
		smsContent = (EditText)this.findViewById(R.id.content);
		
		Button button = (Button)this.findViewById(R.id.Button);
		button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String phoneNumberText = phoneNumber.getText().toString();
				String contentText = smsContent.getText().toString();
				
				SmsManager manager = SmsManager.getDefault();
				ArrayList<String> texts = manager.divideMessage(contentText);
				for(String text: texts){
					manager.sendTextMessage(phoneNumberText, null, text, null, null);
				}
				
				Toast toast=Toast.makeText(SmsMessageActivity.this, "success", Toast.LENGTH_SHORT);
				toast.show();
			}
		});
		
	}

}
